package com.itheima.day05.homework2;

import java.math.BigDecimal;

/*
有以下学员信息：
        张三,男,20,79.5
        李四,女,21,80.2
        王五,男,22,77.9
        周六,男,20,55.8
        赵七,女,21,99.9
        请定义学员类，属性：姓名、性别、年龄、分数
        请编写测试类，创建5个对象，分别存储上述值，并计算5名学员的“平均分”(四舍五入到小数点后2位)。
   */
public class Demo2 {
    public static void main(String[] args) {
        Student student1 = new Student("张三", "男", 20, 79.5);
        Student student2 = new Student("李四", "女", 21, 80.2);
        Student student3 = new Student("王五", "男", 22, 77.9);
        Student student4 = new Student("周六", "男", 20, 55.8);
        Student student5 = new Student("赵七", "女", 21, 99.9);
        BigDecimal score1 = BigDecimal.valueOf(student1.getScore());
        BigDecimal score2 = BigDecimal.valueOf(student2.getScore());
        BigDecimal score3 = BigDecimal.valueOf(student3.getScore());
        BigDecimal score4 = BigDecimal.valueOf(student4.getScore());
        BigDecimal score5 = BigDecimal.valueOf(student5.getScore());
        BigDecimal avg = score1.add(score2).add(score3).add(score4).add(score5).divide(BigDecimal.valueOf(5), 2);
        System.out.println("五位学员的平均分为"+avg);


    }
}
